export interface MenuTreeProps {
  treeData: MenuTreeDataType;
  value?: MenuTreeValueType;
  columnTitle?: Array<string>;
  disabled?: boolean;
  // 是否控制禁用选中
  controlDisabledChecked?: boolean;
  onChange?: (checkedNodes: MenuTreeValueType) => void;
}

export type MenuTreeDataItemType = MenuTreeNodeType | MenuTreeLeafNodeType;
export type MenuTreeDataType = Array<MenuTreeDataItemType>;

// 树节点类型
export type MenuTreeNodeType = {
  key: string | number;
  title: string;
  disabled?: boolean;
  children: Array<MenuTreeDataItemType>;
};

// 树的叶子节点类型
export type MenuTreeLeafNodeType = {
  key: string | number;
  title: string;
  disabled?: boolean;
  operators?: Array<{ label: string; value: string }>;
  multiple?: boolean;
};

export type MenuTreeValueType = Array<MenuTreeValueItemType>;
export type MenuTreeValueItemType = {
  key: string | number;
  title?: string;
  checkedOperators?: Array<string | number>;
  parentKey?: string | number;
};

// 内部状态的类型
export type _MenuTreeValueType = Array<_MenuTreeValueItemType>;
export type _MenuTreeValueItemType = {
  key: string | number;
  parentKey?: string | number;
  isChecked: boolean;
  isAll: boolean;
  title?: string;
  checkedOperators?: Array<string | number>;
};

export type TreeNodeProps = {
  title: string;
  isChecked: boolean;
  isAll: boolean;
  disableChecked: boolean;
  onCheck?: (check: boolean) => void;
};

export type FlatTreeNodeType = {
  key: string | number;
  level: number;
  parentKey: number | string;
  title: string;
} & MenuTreeDataItemType;

export type FlatTreeType = Array<FlatTreeNodeType>;
